<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/3/7
 * Time: 00:37
 */

namespace App\Http\Controllers\Admin;


use App\Http\Logics\Admin\StandardLogic;
use App\Http\Traits\StandardTrait;
use App\Http\Controllers\BaseController;
class StandardController extends BaseController
{
    use StandardTrait;

    /**
     * 获取规格列表
     * @return string
     */
    public function getStandardList()
    {
        $data = [];
        $response = StandardLogic::getStandardList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    public function deleteStandard()
    {
        $standard_id = $this->standard_id;
        $data = [
            'standard_id' => $standard_id
        ];
        $response = StandardLogic::deleteStandard($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    public function createStandard()
    {
        $name = $this->name;
        $data = [
            'name' => $name
        ];
        $response = StandardLogic::createStandard($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    public function updateStandard()
    {
        $standard_id = $this->standard_id;
        $name = $this->name;
        $data = [
            'standard_id' => $standard_id,
            'name' => $name
        ];
        $response = StandardLogic::updateStandard($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * 规格排序
     * @return string
     */
    public function setSort()
    {
        $new_sort_str = $this->new_sort_str;
        $data = [
            'new_sort_str' => $new_sort_str
        ];
        $response = StandardLogic::setSort($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    public function changeStatus()
    {
        $standard_id = $this->standard_id;
        $data = [
            'standard_id' => $standard_id
        ];
        $response = StandardLogic::changeStatus($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}